/* 
 * Qinlan Shen
 * November 8, 2010
 * Pd. 8
 * 
 * Class for everything that moves and has an Image and a hitbox.
 * 
 */
import java.awt.Image;

public class Movable
{
	protected double x;
	protected double y;
	protected double xSpeed;
	protected double ySpeed;
	protected int hitbox;
	protected Image img;
	
	public Movable()
	{
		
	}
	
	public Movable (double xLoc, double yLoc, int h)
	{
		x = xLoc;
		y = yLoc;
		hitbox = h;
	}
	
	public double getX()
	{
		return x;
	}
	
	public double getY()
	{
		return y;
	}
	
	public void setX(int xLoc)
	{
		x = xLoc;
	}
	
	public void setY(int yLoc)
	{
		y = yLoc;
	}
	
	public void setXSpeed(double xS)
	{
		xSpeed = xS;
	}
	
	public void setYSpeed(double yS)
	{
		ySpeed = yS;
	}
	
	public double getXSpeed()
	{
		return xSpeed;
	}
	
	public double getYSpeed()
	{
		return ySpeed;
	}
	
	public int getHitbox()
	{
		return hitbox;
	}
	
	public Image getImage()
	{
		return img;
	}
	
	//If Movable enters the Character's sprite
	public boolean playerHit(Character c)
	{
		int dist = (int)Math.sqrt(Math.pow(x - c.getX(), 2) + Math.pow(y - c.getY(), 2)) - c.getHitbox();
		return (dist < hitbox);
	}
	
	//Updates the Movable's position (can move offscreen)
	public void update()
	{
		x += xSpeed;
		y += ySpeed;
	}
}
